home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 7 / Gekikoh Dennoh Club Vol. 7 (Japan).7z / Gekikoh Dennoh Club Vol. 7 (Japan) (Track 01).bin / tools / motosx / motos.s < prev    next >
Text File  |  1998-02-01  |  20KB  |  806 lines

  1. *========================================================================
  2. *    motos.s
  3. *            Written by Igarashi
  4. *========================================================================
  5.         .cpu    68000
  6. *========================================================================
  7.         .include    doscall.mac
  8.         .include    iocscall.mac
  9. *========================================================================
  10. .ifndef __KEY_INIT
  11. __KEY_INIT    equ    $03
  12. .endif
  13. *========================================================================
  14. SIZEofSYSTEM    equ    $08000
  15. SIZEofSPDATA    equ    $08000
  16. SIZEofBGD001    equ    $02000
  17. SIZEofBGD002    equ    $02000
  18. SIZEofBGD003    equ    $04000
  19. SIZEofMUSD01    equ    $08000
  20. SIZEofMUSD02    equ    $08000
  21. SIZEofMUSD03    equ    $08000
  22. SIZEofMUSD04    equ    $08000
  23. SIZEofM1EXDT    equ    $0a000
  24. SIZEofPCMDAT    equ    $3e000
  25. SIZEofWORK2    equ    $10000
  26. SIZEofMANPRG    equ    $18000
  27. SIZEofROMIMG    equ    $08000
  28. SIZEofWORK1    equ    $10000        *???
  29. SIZEofMUSD00    equ    5786        *これと
  30. SIZEofTTLGRH    equ    3350        * これはアラインしなくていいらしい
  31.  
  32.         .offset    0
  33. SYSTEM:        .ds.b    SIZEofSYSTEM
  34. SPDATA:        .ds.b    SIZEofSPDATA
  35. BGD001:        .ds.b    SIZEofBGD001
  36. BGD002:        .ds.b    SIZEofBGD002
  37. BGD003:        .ds.b    SIZEofBGD003
  38. MUSD01:        .ds.b    SIZEofMUSD01
  39. MUSD02:        .ds.b    SIZEofMUSD02
  40. MUSD03:        .ds.b    SIZEofMUSD03
  41. MUSD04:        .ds.b    SIZEofMUSD04
  42. M1EXDT:        .ds.b    SIZEofM1EXDT
  43. PCMDAT:        .ds.b    SIZEofPCMDAT
  44. WORK2:        .ds.b    SIZEofWORK2
  45. MANPRG:        .ds.b    SIZEofMANPRG
  46. ROMIMG:        .ds.b    SIZEofROMIMG
  47. WORK1:        .ds.b    SIZEofWORK1
  48. MUSD00:        .ds.b    SIZEofMUSD00
  49. TTLGRH        .ds.b    SIZEofTTLGRH
  50. SIZEofMOTOSBUF:
  51.         .text
  52. *========================================================================
  53. NSAVE        equ    33
  54. *========================================================================
  55. CHKCPU        macro    dreg
  56.         moveq.l    #1,dreg
  57.         .cpu    68020
  58.         and.b    *-3(pc,dreg.w*2),dreg
  59.         .cpu    68000
  60.         .endm
  61. *========================================================================
  62.         .text
  63.         .even
  64. *========================================================================
  65. entry:
  66.         lea.l    motos_stack(pc),sp
  67.  
  68.         pea.l    title(pc)
  69.         DOS    __PRINT
  70.         addq.l    #4,sp
  71.  
  72.         move.l    #bottom,d0
  73.         addi.l    #$0000ffff,d0
  74.         clr.w    d0
  75.         movea.l    d0,a5        *a5.l = MOTOSBUF 先頭アドレス
  76.  
  77.         movea.l    a0,a4        *a4 = PSP
  78.         bsr    chkopt
  79.  
  80.         btst.l    #1,d7
  81.         bne    @f
  82.         moveq.l    #0,d1
  83.         moveq.l    #-1,d2
  84.         IOCS    __TGUSEMD
  85.         tst.b    d0
  86.         beq    @f
  87.         subq.b    #3,d0
  88.         bne    gerror
  89. @@:
  90.         bsr    fread
  91.         bsr    patch1
  92.         bsr    patch2
  93.         bsr    patch3
  94.  
  95.         bsr    flushcache
  96.  
  97.         pea.l    0.w
  98.         DOS    __SUPER
  99.         addq.l    #4,sp
  100.         move.l    d0,sspbuf
  101.  
  102.         bsr    savecon
  103.  
  104.         move.w    sr,-(sp)
  105.         ori.w    #$0700,sr
  106.         bsr    savevec
  107.         bsr    chgvec
  108.         bsr    saveMFP
  109.         move.w    (sp)+,sr
  110.  
  111.         moveq.l    #$90,d7        *instead of __BOOTINF
  112.         jmp    SYSTEM(a5)
  113. *------------------------------------------------------------------------
  114. retn:                *キー入力割り込みの途中なんだけど…激ヤバ?
  115.         ori.w    #$0700,sr
  116.  
  117.         lea.l    motos_stack(pc),sp
  118.  
  119.         lea.l    $e88000,a0
  120.         bclr.b    #5,$07(a0)        *IERA    Timer-A禁止
  121.         bclr.b    #3,$09(a0)        *IERB    OPM Timer禁止
  122.         bclr.b    #5,$13(a0)        *IMRA    Timer-Aマスク
  123.         bclr.b    #3,$15(a0)        *IMRB    OPM Timerマスク
  124.         clr.b    $19(a0)            *TACR    いちおう
  125.  
  126.         bsr    stopsnd
  127.  
  128.         bsr    rstrvec
  129.         bsr    rstrMFP
  130.  
  131.         bsr    rstrcon
  132.  
  133.         move.l    sspbuf(pc),-(sp)
  134.         move.l    sp,usp
  135.         DOS    __SUPER
  136.         addq.l    #4,sp
  137.  
  138.         DOS    __EXIT
  139. *------------------------------------------------------------------------
  140. nomemory:    lea.l    nomemmes(pc),a0
  141.         bra    errorexit
  142. rerror:        lea.l    rerrmes(pc),a0
  143.         bra    errorexit
  144. openerror:    lea.l    rerrmes(pc),a0
  145.         bra    errorexit
  146. vererror:    lea.l    vererrmes(pc),a0
  147.         bra    errorexit
  148. gerror:        lea.l    gerrmes(pc),a0
  149.         bra    errorexit
  150. usage:        lea.l    usgmes(pc),a0
  151. errorexit:
  152.         move.w    #2,-(sp)    *STDERR
  153.         pea.l    (a0)
  154.         DOS    __FPUTS
  155.         addq.l    #6,sp
  156.  
  157.         move.w    #1,-(sp)
  158.         DOS    __EXIT2
  159. *------------------------------------------------------------------------
  160. saveMFP:
  161.         lea.l    $e88000,a0
  162.         lea.l    mfpbuf(pc),a1
  163.         move.b    $07(a0),(a1)+        *IERA
  164.         move.b    $09(a0),(a1)+        *IERB
  165.         move.b    $13(a0),(a1)+        *IMRA
  166.         move.b    $15(a0),(a1)+        *IMRB
  167.         move.b    $19(a0),(a1)+        *TACR
  168.         move.b    $1f(a0),(a1)+        *TADR
  169.         rts
  170. rstrMFP:
  171.         lea.l    $e88000,a0
  172.         lea.l    mfpbuf(pc),a1
  173.         move.b    (a1)+,$07(a0)        *IERA
  174.         move.b    (a1)+,$09(a0)        *IERB
  175.         move.b    (a1)+,$13(a0)        *IMRA
  176.         move.b    (a1)+,$15(a0)        *IMRB
  177.         move.b    (a1)+,$19(a0)        *TACR
  178.         move.b    (a1)+,$1f(a0)        *TADR
  179.         rts
  180. *------------------------------------------------------------------------
  181. stopsnd:
  182.         move.w    #$0100,d0    *MIDIがキーオフしないので
  183.         trap    #1        *BGM停止はYODEL DOSに任せる
  184.  
  185.         moveq.l    #$14,d1        *OPMタイマ停止
  186.         moveq.l    #0,d2        *
  187.         IOCS    __OPMSET    *}
  188.  
  189.         moveq.l    #$08,d1        *SEは自前でキーオフ
  190.         moveq.l    #8-1,d2        *
  191. @@:        IOCS    __OPMSET    *
  192.         dbra    d2,@b        *}
  193.  
  194.         bset.b    #4,$e840c7    *DMAC3 CCR    ADPCM停止
  195.         rts
  196. *------------------------------------------------------------------------
  197. savecon:
  198.         IOCS    __MS_CUROF    *マウスカーソル消去
  199. *        moveq.l    #0,d1        *ソフトキーボード消去
  200. *        IOCS    __SKEY_MOD    *}
  201.  
  202.         moveq.l    #0,d1        *グラフィック画面・テキスト画面使用中
  203.         moveq.l    #2,d2        *
  204.         IOCS    __TGUSEMD    *
  205.         moveq.l    #1,d1        *
  206. *        moveq.l    #2,d2        *
  207.         IOCS    __TGUSEMD    *}
  208.  
  209.         IOCS    __LEDMOD    *LED取得
  210.         move.w    d0,ledbuf    *}
  211.  
  212.         pea.l    $0010ffff    *画面モード取得
  213.         DOS    __CONCTRL    *(sp).w = 16, 2(sp).w = -1
  214.         addq.l    #4,sp        *
  215.         move.w    d0,crtmodbuf    *}
  216.  
  217.         rts
  218. *------------------------------------------------------------------------
  219. rstrcon:
  220.         move.w    #$01f0,$e8002a    *テキストクリア
  221.         lea.l    $e00000,a0    *
  222.         moveq.l    #0,d0        *
  223.         move.w    #1024-1,d1    *
  224. 1:        move.w    #128-1,d2    *
  225. 2:        move.w    d0,(a0)+    *
  226.         dbra    d2,2b        *
  227.         dbra    d1,1b        *}
  228.  
  229.         bclr.b    #1,$e8e007    *for screen mode 384*256
  230.  
  231.         move.w    crtmodbuf(pc),-(sp)    *画面モード復帰
  232.         move.w    #16,-(sp)        *
  233.         DOS    __CONCTRL        *
  234.         addq.l    #4,sp            *}
  235.         move.w    #17,-(sp)        *カーソル表示
  236.         DOS    __CONCTRL        *
  237.         addq.l    #2,sp            *}
  238.  
  239.         move.w    ledbuf+1(pc),d1
  240.         IOCS    __KEY_INIT
  241.  
  242.         moveq.l    #0,d1        *グラフィック画面・テキスト画面解放
  243.         moveq.l    #3,d2        *
  244.         IOCS    __TGUSEMD    *
  245.         moveq.l    #1,d1        *
  246. *        moveq.l    #3,d2        *
  247.         IOCS    __TGUSEMD    *}
  248.  
  249.         moveq.l    #-1,d1        *ソフトキーボード自動制御
  250.         IOCS    __SKEY_MOD    *}
  251.  
  252.         rts
  253. *------------------------------------------------------------------------
  254. savevec:
  255.         lea.l    vecnotbl(pc),a0
  256.         lea.l    vecbuf(pc),a1
  257.  
  258.         moveq.l    #NSAVE-1,d1
  259.         clr.w    -(sp)
  260. @@:        move.b    (a0)+,1(sp)
  261.         DOS    __INTVCG
  262.         move.l    d0,(a1)+
  263.         dbra    d1,@b
  264.         addq.l    #2,sp
  265.  
  266.         rts
  267. *------------------------------------------------------------------------
  268. chgvec:
  269.         pea.l    trap04entry(pc)
  270.         move.w    #$24,-(sp)
  271.         DOS    __INTVCS
  272.         addq.l    #6,sp
  273.         rts
  274. *------------------------------------------------------------------------
  275. trap04entry:            *not for 68000
  276.         addq.l    #8,sp
  277.         move.w    (sp)+,sr
  278.         rts
  279. *------------------------------------------------------------------------
  280. rstrvec:
  281. .if 0
  282.         lea.l    vecnotbl(pc),a0
  283.         lea.l    vecbuf(pc),a1
  284.  
  285.         moveq.l    #NSAVE-1,d1
  286.         subq.l    #6,sp
  287.         clr.w    (sp)
  288. @@:        move.l    (a1)+,2(sp)
  289.         move.b    (a0)+,1(sp)
  290.         DOS    __INTVCS
  291.         dbra    d1,@b
  292.         addq.l    #6,sp
  293. .else
  294.         lea.l    vecnotbl(pc),a2
  295.         lea.l    vecbuf(pc),a3
  296.  
  297.         moveq.l    #NSAVE-1,d2
  298.         clr.w    d1
  299. @@:        move.b    (a2)+,d1
  300.         move.l    (a3)+,a1
  301.         IOCS    __B_INTVCS
  302.         dbra    d2,@b
  303. .endif
  304.         rts
  305. *------------------------------------------------------------------------
  306. fread:
  307.         movea.l    a5,a0
  308.         adda.l    #SIZEofMOTOSBUF,a0
  309.         cmpa.l    12(a4),a0    *pspMEMEND
  310.         bhi    nomemory
  311.  
  312.         lea.l    freadtbl(pc),a1
  313.         bra    freadnext
  314. freadlp:    movem.l    (a1)+,d1-d3
  315.         clr.w    -(sp)
  316.         move.l    d1,-(sp)
  317.         DOS    __OPEN
  318.         addq.l    #6,sp
  319.         move.l    d0,d4
  320.         bmi    openerror
  321.         move.l    d3,-(sp)
  322.         pea.l    0(a5,d2.l)
  323.         move.w    d4,-(sp)
  324.         DOS    __READ
  325.         lea.l    10(sp),sp
  326.         tst.l    d0
  327.         bmi    rerror
  328.         move.w    d4,-(sp)
  329.         DOS    __CLOSE
  330.         addq.l    #2,sp
  331. freadnext:    tst.l    (a1)
  332.         bne    freadlp
  333.         rts
  334. *------------------------------------------------------------------------
  335. freadtbl:    .dc.l    fn00,SYSTEM,SIZEofSYSTEM
  336.         .dc.l    fn01,SPDATA,SIZEofSPDATA
  337.         .dc.l    fn02,BGD001,SIZEofBGD001
  338.         .dc.l    fn03,BGD002,SIZEofBGD002
  339.         .dc.l    fn04,BGD003,SIZEofBGD003
  340.         .dc.l    fn05,MUSD01,SIZEofMUSD01
  341.         .dc.l    fn06,MUSD02,SIZEofMUSD02
  342.         .dc.l    fn07,MUSD03,SIZEofMUSD03
  343.         .dc.l    fn08,MUSD04,SIZEofMUSD04
  344.         .dc.l    fn09,M1EXDT,SIZEofM1EXDT
  345.         .dc.l    fn10,PCMDAT,SIZEofPCMDAT
  346.         .dc.l    fn11,MANPRG,SIZEofMANPRG
  347.         .dc.l    fn12,ROMIMG,SIZEofROMIMG
  348.         .dc.l    fn13,MUSD00,SIZEofMUSD00
  349.         .dc.l    fn14,TTLGRH,SIZEofTTLGRH
  350.         .dc.l    0
  351.  
  352. fn00:        .dc.b    'SYSTEM',0
  353. fn01:        .dc.b    'SPDATA',0
  354. fn02:        .dc.b    'BGD001',0
  355. fn03:        .dc.b    'BGD002',0
  356. fn04:        .dc.b    'BGD003',0
  357. fn05:        .dc.b    'MUSD01',0
  358. fn06:        .dc.b    'MUSD02',0
  359. fn07:        .dc.b    'MUSD03',0
  360. fn08:        .dc.b    'MUSD04',0
  361. fn09:        .dc.b    'M1EXDT',0
  362. fn10:        .dc.b    'PCMDAT',0
  363. fn11:        .dc.b    'MANPRG',0
  364. fn12:        .dc.b    'ROMIMG',0
  365. fn13:        .dc.b    'MUSD00',0
  366. fn14:        .dc.b    'TTLGRH',0
  367.  
  368.         .even
  369. *------------------------------------------------------------------------
  370. chkopt:
  371.         moveq.l    #0,d7
  372.         addq.l    #1,a2
  373. optlp:        move.b    (a2)+,d0
  374.         beq    optretn
  375.         cmpi.b    #' ',d0
  376.         beq    optlp
  377.         cmpi.b    #'    ',d0
  378.         beq    optlp
  379.         cmpi.b    #'-',d0
  380.         bne    usage
  381.         moveq.l    #$20,d0
  382.         or.b    (a2)+,d0
  383.         cmpi.b    #'r',d0
  384.         beq    ropt
  385.         cmpi.b    #'g',d0
  386.         beq    gopt
  387.         bra    usage
  388. ropt:        move.b    (a2)+,d0
  389.         cmpi.b    #'0',d0
  390.         beq    ropt0
  391.         cmpi.b    #'1',d0
  392.         beq    ropt1
  393.         bra    usage
  394. ropt0:        bclr.l    #0,d7
  395.         bra    optlp
  396. ropt1:        bset.l    #0,d7
  397.         bra    optlp
  398. gopt:        bset.l    #1,d7
  399.         bra    optlp
  400. optretn:    rts
  401. *------------------------------------------------------------------------
  402. *    MPUキャッシュのフラッシュ
  403. *        in:    none
  404. *        out:    none
  405. *        broken:    none
  406. *------------------------------------------------------------------------
  407. flushcache:
  408. SAVREGS        reg    d0/d1
  409.         movem.l    SAVREGS,-(sp)
  410.         CHKCPU    d0
  411.         beq    @f
  412.         moveq.l    #3,d1        *flush
  413.         moveq.l    #$ac,d0        *SYS_STAT
  414.         trap    #15
  415. @@:        movem.l    (sp)+,SAVREGS
  416.         rts
  417. *------------------------------------------------------------------------
  418. patch1:
  419.         CHKCPU    d0
  420.         beq    nortepatch
  421.         lea.l    pattbl0(pc),a0
  422.         move.w    #$4e44,d0
  423.         move.w    #$4e73,d1
  424.         bsr    patch_short    *rte -> trap #4
  425.                     *「ストライダー飛竜」の030パッチで
  426.                     *使われていた技
  427.                     *040や060では動くのだろうか?
  428. nortepatch:
  429.         lea.l    pattbl1(pc),a0
  430.         move.w    #$4e75,d0
  431.         move.w    #$48e7,d1
  432.         bsr    patch_short        *movem -> rts
  433.  
  434.         lea.l    pattbl2(pc),a0
  435.         move.w    #$4e71,d0
  436.         move.w    #$4250,d1
  437.         bsr    patch_short        *clr.w (a0) -> nop
  438.  
  439.         lea.l    pattbl_stack(pc),a0    *スタック
  440.         move.l    #motos_stack,d0        *
  441.         move.l    #$004000,d1        *
  442.         bsr    patch_long        *}
  443.  
  444.         lea.l    pattbl_spdata(pc),a0    *SPDATA
  445.         move.l    a5,d0            *
  446.         addi.l    #SPDATA,d0        *
  447.         move.l    #$018000,d1        *
  448.         bsr    patch_long        *}
  449.  
  450.         lea.l    pattbl_bgd001(pc),a0    *BGD001
  451.         move.l    a5,d0            *
  452.         addi.l    #BGD001,d0        *
  453.         move.l    #$020000,d1        *
  454.         bsr    patch_long        *}
  455.  
  456.         lea.l    pattbl_bgd002(pc),a0    *BGD002
  457.         move.l    a5,d0            *
  458.         addi.l    #BGD002,d0        *
  459.         move.l    #$022000,d1        *
  460.         bsr    patch_long        *}
  461.  
  462.         lea.l    pattbl_bgd003(pc),a0    *BGD003
  463.         move.l    a5,d0            *
  464.         addi.l    #BGD003,d0        *
  465.         move.l    #$024000,d1        *
  466.         bsr    patch_long        *}
  467.  
  468.         lea.l    pattbl_ttlgrh(pc),a0    *TTLGRH
  469.         move.l    a5,d0            *
  470.         addi.l    #TTLGRH,d0        *
  471.         move.l    #$028000,d1        *
  472.         bsr    patch_long        *}
  473.  
  474.         lea.l    pattbl_musd01(pc),a0    *MUSD01
  475.         move.l    a5,d0            *
  476.         addi.l    #MUSD01,d0        *
  477.         move.l    #$028000,d1        *
  478.         bsr    patch_long        *}
  479.  
  480.         lea.l    pattbl_musd02(pc),a0    *MUSD02
  481.         move.l    a5,d0            *
  482.         addi.l    #MUSD02,d0        *
  483.         move.l    #$030000,d1        *
  484.         bsr    patch_long        *}
  485.  
  486.         lea.l    pattbl_musd03(pc),a0    *MUSD03
  487.         move.l    a5,d0            *
  488.         addi.l    #MUSD03,d0        *
  489.         move.l    #$038000,d1        *
  490.         bsr    patch_long        *}
  491.  
  492.         lea.l    pattbl_musd04(pc),a0    *MUSD04
  493.         move.l    a5,d0            *
  494.         addi.l    #MUSD04,d0        *
  495.         move.l    #$040000,d1        *
  496.         bsr    patch_long        *}
  497.  
  498.         lea.l    pattbl_m1exdt(pc),a0    *M1EXDT
  499.         move.l    a5,d0            *
  500.         addi.l    #M1EXDT,d0        *
  501.         move.l    #$048000,d1        *
  502.         bsr    patch_long        *}
  503.  
  504.         lea.l    pattbl_musd00(pc),a0    *MUSD00
  505.         move.l    a5,d0            *
  506.         addi.l    #MUSD00,d0        *
  507.         move.l    #$048010,d1        *
  508.         bsr    patch_long        *}
  509.  
  510.         lea.l    pattbl_pcmdat(pc),a0    *PCMDAT
  511.         move.l    a5,d0            *
  512.         addi.l    #PCMDAT,d0        *
  513.         move.l    #$052000,d1        *
  514.         bsr    patch_long        *}
  515.  
  516.         lea.l    pattbl3(pc),a0        *TTLGRH展開バッファ (らしい)
  517.         move.l    a5,d0            * オリジナルではPCM用バッファを
  518.         addi.l    #WORK1,d0        * 使用しているが、都合によりWORK1を使用
  519.         move.l    #$052000,d1        *
  520.         bsr    patch_long        *}
  521.  
  522.         lea.l    pattbl_manprg(pc),a0    *MANPRG
  523.         move.l    a5,d0            *
  524.         addi.l    #MANPRG,d0        *
  525.         move.l    #$0a0000,d1        *
  526.         bsr    patch_long        *}
  527.  
  528.         lea.l    pattbl_work2(pc),a0    *WORK2
  529.         move.l    a5,d0            *
  530.         addi.l    #WORK2,d0        *
  531.         move.l    #$090000,d1        *
  532.         bsr    patch_long        *}
  533.  
  534.         lea.l    pattbl_work1(pc),a0    *WORK1
  535.         move.l    a5,d0            *
  536.         addi.l    #WORK1,d0        *
  537.         move.l    #$0c0000,d1        *
  538.         bsr    patch_long        *}
  539.  
  540.         bsr    patch_special
  541.  
  542.         rts
  543.  
  544. patch_special:
  545.         lea.l    pattbl_sp1(pc),a0
  546.         move.l    a5,d0
  547.         addi.l    #WORK1,d0
  548.         swap.w    d0
  549.         move.l    #.highw.$0c0000,d1
  550.         bra    2f
  551. 1:        cmp.w    0(a5,d2.l),d1
  552.         bne    vererror
  553.         move.w    (a0)+,d3
  554.         cmp.w    2(a5,d2.l),d3
  555.         bne    vererror
  556.         move.w    d0,0(a5,d2.l)
  557. 2:        move.l    (a0)+,d2
  558.         bne    1b
  559.  
  560.         lea.l    pattbl_sp2(pc),a0
  561.         movea.l    a5,a1
  562.         adda.l    #MANPRG+$0079fa,a1
  563. *        move.l    a5,d0
  564. *        addi.l    #WORK1,d0
  565. *        swap.w    d0
  566. *        move.l    #.highw.$0c0000,d1
  567.         bra    4f
  568. 3:        cmp.w    2(a1),d1
  569.         bne    vererror
  570.         move.w    d0,(a1)
  571.         addq.l    #4,a1
  572. 4:        move.w    (a0)+,d1
  573.         bne    3b
  574.  
  575.         rts
  576. *------------------------------------------------------------------------
  577. patch2:                *DOS復帰パッチ
  578.         lea.l    pattbl4(pc),a0
  579.         move.w    #$7007,d0
  580.         move.w    #$7006,d1
  581.         bsr    patch_short
  582.         lea.l    pattbl5(pc),a0
  583.         move.w    #$4ef9,d0
  584.         move.w    #$b03c,d1
  585.         bsr    patch_short
  586.         lea.l    pattbl6(pc),a0
  587.         move.l    #chkexitkey,d0
  588.         move.l    #$000666f2,d1
  589.         bsr    patch_long    *-> jmp chkexitkey.l
  590.  
  591.         move.l    a5,d0
  592.         addi.l    #SYSTEM+$04b8,d0
  593.         move.l    d0,selfpat+2
  594.  
  595.         rts
  596. chkexitkey:
  597.         cmpi.b    #$01,d0
  598.         beq    chkiocs        *SHIFT+DEL
  599.         cmpi.b    #$06,d0
  600.         bne    nojob
  601. selfpat:    jmp    0.l        *SHIFT+CTRL+DEL -> reset
  602. chkiocs:    cmpi.w    #-1,$0a0e.w    *ほとんどあり得ないけど
  603.         beq    retn        *IOCSコール発行中か調べてみる
  604. nojob:        rts
  605. *------------------------------------------------------------------------
  606. patch3:                *オプションによるパッチ
  607.                 *画面モード
  608.         btst.l    #0,d7
  609.         beq    @f
  610.         lea.l    pattbl7(pc),a0
  611.         move.w    #$4e71,d0
  612.         move.w    #$5250,d1
  613.         bsr    patch_short    *addq.w #1,(a0) -> nop
  614.         lea.l    pattbl8(pc),a0
  615.         move.w    #$0001,d0
  616.         move.w    #$0000,d1
  617.         bsr    patch_short    *CRT MODE
  618. @@:        rts
  619. *------------------------------------------------------------------------
  620. patch_short0:
  621.         cmp.w    0(a5,d2.l),d1
  622.         bne    vererror
  623.         move.w    d0,0(a5,d2.l)
  624. patch_short:    move.l    (a0)+,d2
  625.         bne    patch_short0
  626.         rts
  627.  
  628. patch_long0:
  629.         cmp.l    0(a5,d2.l),d1
  630.         bne    vererror
  631.         move.l    d0,0(a5,d2.l)
  632. patch_long:    move.l    (a0)+,d2
  633.         bne    patch_long0
  634.         rts
  635. *------------------------------------------------------------------------
  636. pattbl0:    .dc.l    SYSTEM+$0003f2,SYSTEM+$000400,SYSTEM+$00067e
  637.         .dc.l    SYSTEM+$0007ea,SYSTEM+$000804,SYSTEM+$000952
  638.         .dc.l    SYSTEM+$000956,SYSTEM+$0009fc,SYSTEM+$000ac6
  639.         .dc.l    SYSTEM+$000b28,SYSTEM+$000b64,SYSTEM+$00139e
  640.         .dc.l    SYSTEM+$002220,SYSTEM+$002258,SYSTEM+$0022a6
  641.         .dc.l    SYSTEM+$0022be,SYSTEM+$0022d4,SYSTEM+$0022f8
  642.         .dc.l    SYSTEM+$002314,SYSTEM+$002350,SYSTEM+$002362
  643.         .dc.l    SYSTEM+$002aa0,SYSTEM+$002c92
  644.         .dc.l    MANPRG+$00738c,MANPRG+$007408
  645.         .dc.l    0
  646. pattbl1:    .dc.l    SYSTEM+$000030
  647.         .dc.l    0
  648. pattbl2:    .dc.l    SYSTEM+$002904
  649.         .dc.l    0
  650. pattbl3:    .dc.l    SYSTEM+$002e1e,SYSTEM+$002e2a
  651.         .dc.l    0
  652. pattbl_spdata:    .dc.l    MANPRG+$73ea
  653.         .dc.l    MANPRG+$7516
  654.         .dc.l    MANPRG+$776e
  655.         .dc.l    0
  656. pattbl_bgd001:    .dc.l    MANPRG+$006b10
  657.         .dc.l    MANPRG+$0077de
  658.         .dc.l    0
  659. pattbl_bgd002:    .dc.l    MANPRG+$0077e6
  660.         .dc.l    0
  661. pattbl_bgd003:    .dc.l    MANPRG+$0077ee
  662.         .dc.l    0
  663. pattbl_ttlgrh:    .dc.l    SYSTEM+$002ca4
  664.         .dc.l    0
  665. pattbl_manprg:    .dc.l    SYSTEM+$0028bc
  666.         .dc.l    0
  667. pattbl_pcmdat:    .dc.l    SYSTEM+$002958
  668.         .dc.l    0
  669. pattbl_musd00:    .dc.l    SYSTEM+$002f2e
  670.         .dc.l    0
  671. pattbl_musd01:    .dc.l    SYSTEM+$00296c,SYSTEM+$002976
  672.         .dc.l    MANPRG+$0019a2
  673.         .dc.l    0
  674. pattbl_musd02:    .dc.l    SYSTEM+$002982,SYSTEM+$00298c
  675.         .dc.l    MANPRG+$0019a6
  676.         .dc.l    0
  677. pattbl_musd03:    .dc.l    MANPRG+$0019aa
  678.         .dc.l    0
  679. pattbl_musd04:    .dc.l    MANPRG+$0019ae
  680.         .dc.l    0
  681. pattbl_m1exdt:    .dc.l    MANPRG+$001912,MANPRG+$00192a
  682.         .dc.l    0
  683. pattbl_stack:    .dc.l    MANPRG+$00001e,MANPRG+$0023d2
  684.         .dc.l    0
  685. pattbl_work2:    .dc.l    MANPRG+$0073a2,MANPRG+$00740c,MANPRG+$0076d0
  686.         .dc.l    0
  687. pattbl_work1:    .dc.l    MANPRG+$000024,MANPRG+$0000b4,MANPRG+$0003a2
  688.         .dc.l    MANPRG+$0067ae,MANPRG+$0067d0,MANPRG+$006990
  689.         .dc.l    0
  690. pattbl_sp1:    .dc.l    MANPRG+$001022
  691.         .dc.w    $a000
  692.         .dc.l    MANPRG+$001098
  693.         .dc.w    $bffc
  694.         .dc.l    MANPRG+$0010c8
  695.         .dc.w    $bffc
  696.         .dc.l    MANPRG+$0010fe
  697.         .dc.w    $fffc
  698.         .dc.l    MANPRG+$001138
  699.         .dc.w    $fffc
  700.         .dc.l    MANPRG+$001236
  701.         .dc.w    $bffc
  702.         .dc.l    MANPRG+$001244
  703.         .dc.w    $bffc
  704.         .dc.l    MANPRG+$0026c0
  705.         .dc.w    $dffc
  706.         .dc.l    MANPRG+$002810
  707.         .dc.w    $dffc
  708.         .dc.l    0
  709. pattbl_sp2:    .dc.w    $07dd,$07dc,$07db,$07da,$07d9,$07d8,$07d7,$07d6
  710.         .dc.w    $07d5,$07d4,$07d3,$07d2,$07c1,$07c0,$07cf,$07ce
  711.         .dc.w    $07cd,$07cc,$07cb,$07ca,$07c9,$07c8,$07c7,$07c6
  712.         .dc.w    $07c5,$07c4,$07c3,$07c2,$07fd,$07fc,$07fb,$07fa
  713.         .dc.w    $07f9,$07f8,$07f7,$07f6,$07f5,$07f4,$07f3,$07f2
  714.         .dc.w    $07e1,$07e0,$07ef,$07ee,$07ed,$07ec,$07eb,$07ea
  715.         .dc.w    $07e9,$07e8,$07e7,$07e6,$07e5,$07e4,$07e3,$07e2
  716.         .dc.w    $039f,$039e,$035f,$035e,$031f,$031e,$02df,$02de
  717.         .dc.w    $029f,$029e,$025f,$025e,$021f,$021e,$01df,$01de
  718.         .dc.w    $019f,$019e,$037f,$037e,$033f,$033e,$02ff,$02fe
  719.         .dc.w    $02bf,$02be,$027f,$027e,$023f,$023e,$01ff,$01fe
  720.         .dc.w    $01bf,$01be,$017f,$017e,$07bc,$079c,$07ba,$079a
  721.         .dc.w    $07b8,$0798,$07b6,$0796,$07b4,$0794,$07b2,$0792
  722.         .dc.w    $07a0,$0780,$07ae,$078e,$07ac,$078c,$07bb,$079b
  723.         .dc.w    $07b9,$0799,$07b7,$0797,$07b5,$0795,$07b3,$0793
  724.         .dc.w    $07b1,$0791,$079f,$079f,$07ad,$078d,$07ab,$078b
  725.         .dc.w    0
  726. pattbl4:    .dc.l    SYSTEM+$0004ac
  727.         .dc.l    0
  728. pattbl5:    .dc.l    SYSTEM+$0004b2
  729.         .dc.l    0
  730. pattbl6:    .dc.l    SYSTEM+$0004b4
  731.         .dc.l    0
  732. pattbl7:    .dc.l    SYSTEM+$002818
  733.         .dc.l    0
  734. pattbl8:    .dc.l    SYSTEM+$002aa2
  735.         .dc.l    0
  736. *------------------------------------------------------------------------
  737. vecnotbl:            *パッチ箇所を増やす場合は定数NSAVEを変更すること
  738.                 *SYSTEM
  739.         .dc.b    $02        *Bus Error
  740.         .dc.b    $03        *Address Error
  741.         .dc.b    $04        *Illegal Instruction
  742.         .dc.b    $05        *Zero Divide
  743.         .dc.b    $06        *CHK, CHK2 Instruction
  744.         .dc.b    $07        *cpTRAPcc, TRAPcc, TRAPV Instruction
  745.         .dc.b    $08        *Privilege Violation
  746.         .dc.b    $09        *Trace
  747.         .dc.b    $0a        *Line 1010 Emulator
  748.         .dc.b    $0b        *Line 1111 Emulator
  749.         .dc.b    $0f        *Uninitialized Interrupt
  750.         .dc.b    $18        *Spurious Interrupt
  751.         .dc.b    $1f        *Level7 Interrupt Auto Vector
  752.         .dc.b    $20        *TRAP #0 Instruction
  753.         .dc.b    $21        *TRAP #1 Instruction
  754.         .dc.b    $22        *TRAP #2 Instruction
  755.         .dc.b    $23        *TRAP #3 Instruction
  756.         .dc.b    $43        *MFP OPM Timer
  757.         .dc.b    $49        *MFP USART Tx Error
  758.         .dc.b    $4a        *MFP USART Tx Buffer Empty
  759.         .dc.b    $4b        *MFP USART Rx Error
  760.         .dc.b    $4c        *MFP USART Rx Buffer Full
  761.         .dc.b    $4d        *MFP Timer-A
  762.         .dc.b    $6a        *DMAC Ch.3 Normal
  763.         .dc.b    $80
  764.         .dc.b    $82
  765.         .dc.b    $84
  766.         .dc.b    $86
  767.         .dc.b    $88
  768.         .dc.b    $8a
  769.         .dc.b    $8c
  770.         .dc.b    $8e
  771.                 *motos.x
  772.         .dc.b    $24        *TRAP #4 Instruction
  773. *------------------------------------------------------------------------
  774. title:        .dc.b    'MOTOS for X680x0'
  775.         .dc.b    ' modified for Human68k 1998 Igarashi'
  776.         .dc.b    $0d,$0a,0
  777. usgmes:        .dc.b    'usage: motos [option]',$0d,$0a
  778.         .dc.b    '    -r<num>    画面モード (0:256*256/1:384*256)',$0d,$0a
  779.         .dc.b    '    -g    グラフィック画面を強制使用する',$0d,$0a,0
  780. nomemmes:    .dc.b    'メモリが足りません',$0d,$0a,0
  781. openerrmes:    .dc.b    'ファイルが見つかりません',$0d,$0a,0
  782. rerrmes:    .dc.b    'ファイルが読み込めません',$0d,$0a,0
  783. vererrmes:    .dc.b    'バージョンが違うようです',$0d,$0a,0
  784. gerrmes:    .dc.b    'グラフィック画面が使用中です。起動できません',$0d,$0a,0
  785. *========================================================================
  786.         .bss
  787.         .even
  788. *------------------------------------------------------------------------
  789. ledbuf:        .ds.w    1
  790. crtmodbuf:    .ds.w    1
  791. uspbuf:        .ds.l    1
  792. sspbuf:        .ds.l    1
  793. vecbuf:        .ds.l    NSAVE
  794. mfpbuf:        .ds.b    6
  795. *========================================================================
  796.         .stack
  797.         .even
  798. *------------------------------------------------------------------------
  799.         .ds.l    $2800/4
  800. motos_stack:
  801. *========================================================================
  802. bottom:
  803. *========================================================================
  804.         .end    entry
  805.  
  806.